﻿@using NigiriClub.WebUI.Models
@model NigiriClub.WebUI.Models.Game

@using NigiriClub.WebUI.Models

@{Account loggedIn = Account.GetAccount(User.Identity.Name);}

@{
    Game game = null;
    int level = 0;
    if (loggedIn != null)
    {
        using (var db = new Entities())
        {

            level = loggedIn.Level == null ? 0 : (int)loggedIn.Level;
            game = db.Game.FirstOrDefault(n => n.ReviewerId == loggedIn.Id && !n.IsReviewed);
        }
    }
}

<tr>
    <td>@Html.Action("ProfileLinkById", "Profile", new { id = @Model.OwnerId })</td>
    <td>@Model.WhiteName</td>
    <td>@Model.BlackName</td>
    <td>@Model.Level</td>
    <td><a href="Games/Show/@Model.Id"><span class="glyphicon glyphicon-eye-open"></span></a>
        <a href="@Model.Path"><span class="glyphicon glyphicon-floppy-disk"></span></a></td>
    <td>@if (loggedIn != null)
        {
            if (game == null && level > Model.Level + 200 && !Model.IsReviewed && Model.ReviewerId == null)
            {
        <a href="Games/Review/@Model.Id"><span class="glyphicon glyphicon-edit"></span></a>
            }
            if (Account.GetAccount(User.Identity.Name).PermissionId == 2 || Model.OwnerId == loggedIn.Id)
            {
        <a href="Games/DeleteGame/@Model.Id"><span class="glyphicon glyphicon-remove"></span></a>
            }
        }
    </td>
</tr>
